package com.amc.wxSend.feignClient.fallback;

import com.amc.framework.web.domain.R;
import com.amc.wxSend.feignClient.WxSendServiceFeignClient;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 微信发送服务降级处理
 *
 * @author ZhangXX
 * @date @2023/6/21 9:12
 */
@Component
public class WxSendServiceFallbackFactory implements FallbackFactory<WxSendServiceFeignClient> {
    private static final Logger log = LoggerFactory.getLogger(WxSendServiceFallbackFactory.class);

    @Override
    public WxSendServiceFeignClient create(Throwable throwable) {
        log.error("微信发送服务调用失败:{}", throwable.getMessage());
        return (sysType, batchCode) -> R.fail("微信发送服务调用失败:{}", throwable.getMessage());
    }
}
